/**
 * 27/12/2013
 * 
 * Paddle
 * 
 * Copyright GPL
 */
package com.jtmproject;

import java.io.Serializable;

import com.badlogic.gdx.math.Vector3;

/**
 * Represents the paddle of the world
 * 
 * @author Pello Altadill
 */
public class Paddle implements Serializable {
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -2394358953962148701L;

	//this controls the "y" distance
	private final float SPEED = 10.5f;
	
	private Vector3 position;
	private Vector3 direction;
	private float x = 0;
	private float y = 0;
	private int goalsTaked = 0;
	
	/**
	 * constructor. Initializes the speeds and the position
	 * @param x
	 * @param y
	 */
	public Paddle(float x, float y, int goalsTaked){
		this.x = x;
		this.y = y;
		this.goalsTaked = goalsTaked;
		position = new Vector3(this.x, this.y, 0);
		direction = new Vector3(SPEED, SPEED, 0);
	}
	
	/**
	 * mover
	 * mueve la posición de la pala. Se controla para que no se
	 * salga de los márgenes.
	 * @param x
	 */
	public void move(float x) {
		if(x < 0){
			x = 0;
		} 
		
		if(x > GameValues.AXIS_X - 3){
			x = GameValues.AXIS_X - 3;
		} 
		position.x = x;
	}

	/**
	 * returns the position
	 * @return
	 */
	public Vector3 getPosition() {
		return position;
	}

	/**
	 * sets the position
	 * @param position
	 */
	public void setPosition(Vector3 position) {
		this.position = position;
	}

	/**
	 * returns the direction
	 * @return
	 */
	public Vector3 getDirection() {
		return direction;
	}

	/**
	 * sets the position
	 * @param direction
	 */
	public void setDirection(Vector3 direction) {
		this.direction = direction;
	}

	/**
	 * returns the goals taked
	 * @return
	 */
	public int getGoalsTaked() {
		return goalsTaked;
	}

	/**
	 * adds the goals taked
	 */
	public void addGoal() {
		goalsTaked++;
	}

}
